<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4254：Aerial Tramway </title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Aerial Tramway </a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Aerial Tramway </span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Aerial Tramway                 </h1>
                <p>时间限制：1s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>You own a park located on a mountain, which can be described as a sequence of n points (xi, yi) from left to right, where xi,yi&gt;0, xi&lt;xi+1, yi!=yi+1 &nbsp;(that means there will not be horizontal segments in the mountain skyline), illustrated below(the numbers are the corresponding x-coordinate):&nbsp;</div>
<div><img src="../file/4254_0.png" width="754" height="277" alt="" /></div>
<div></div>
<div>You own a park located on a mountain, which can be described as a sequence of n points (xi, yi) from left to right, where xi,yi&gt;0, xi&lt;xi+1, yi!=yi+1 &nbsp;(that means there will not be horizontal segments in the mountain skyline), illustrated below(the numbers are the corresponding x-coordinate): Since the mountain is very sloppy, some aerial tramways across the park would be very helpful. In the figure above, people can go from p4 to p9 directly, by taking a tram. Otherwise he must follow a rather&nbsp;</div>
<div>zigzag path: p4-p5-p6-p7-p8-p9.&nbsp;</div>
<div>Your job is to design an aerial tramway system. There should be exactly m &nbsp;trams, each following a horizontal &nbsp;segment in the air, &nbsp;between &nbsp;two points pi &nbsp;and pj. &quot;Horizontal&quot; means yi=yj, &nbsp;&ldquo;in the air&quot; means all the points in between are strictly below, i.e. yk&lt;yi for every i&lt;k&lt;j. For example, no tram can travel between p2 and p9, because p4 is not strictly below p2-p9. However, you can have two trams, one&nbsp;</div>
<div>from p2 to p4, and one p4 to p9. There is another important restriction: no point can be strictly below k or more tramways, because it&rsquo;ll be dangerous. For example, if k=3, we cannot build these 3 tramways simultaneously: p1-p14, p4-p9, p6-p8, because p7 would be dangerous. You want to make this system as useful as possible, so you would like to maximize the total length of all tramways. For example, if m=3, k=3, the best design for the figure above is p1-p14, p2-p4 and p4-p9,the total length is 20. If m=3, k=2, you have to replace p1-p14 with p11-p13, the total length becomes 9.&nbsp;</div>
<p></p></p><hr/><h3>输入格式</h3><p><div>There will be at most 200 test cases. Each case begins with three integers n, m and k(1&lt;=n,m&lt;=200, 2&lt;=k&lt;=10), the number of points, the number of trams in your design and the dangerous parameter introduced earlier. The next line contains n pairs of positive integers xi and yi.(1&lt;=xi,yi&lt;=10^5).&nbsp;&nbsp;</div>
<div></div>
<p></p></p><hr/><h3>输出格式</h3><p><div>For each test case, print the case number and the maximal sum. If it is impossible to have exactly m tramways, print -1.&nbsp;</div>
<div></div>
<p></p></p><hr/><h3>样例输入</h3><pre>14 3 3 
1 8 
2 6 
3 4 
4 6 
5 3 
6 4 
7 1 
8 4 
9 6 
10 4 
11 6 
12 5 
13 6 
14 8 
14 3 2 
1 8 
2 6 
3 4 
4 6 
5 3 
6 4 
7 1 
8 4 
9 6 
10 4 
11 6 
12 5 
13 6 
14 8 </pre><hr/><h3>样例输出</h3><pre>Case 1: 20 
Case 2: 9 </pre><hr/><h3>提示</h3><p><p>&nbsp;2015年湖南省大学生程序设计竞赛</p></p><hr/><h3>题目来源</h3><p>鸣谢刘汝佳先生授权使用</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4254" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4254" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>